﻿<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {

    }


    [DirectMethod]
    public void CustomersOnTriggerClick()
    {
        X.AddScript("CustomerStore.reload()");
    }

    [DirectMethod]
    public void ProductsOnTriggerClick()
    {
        X.AddScript("ProductsStore.reload()");
    }
    
    
</script>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
    <script type="text/javascript" src="/Scripts/Commen.js"></script>
    <script type="text/javascript" src="/Scripts/INV_ShortageOrder/Inv_ShortageOrder_Index.js"></script>
    <script type="text/javascript">
        var orderStatus = function (value) {
            if ("Invalid" == value)
                return "已核销";
            if ("Valid" == value)
                return "欠货";
            return "未知";
        };

        var prepare = function (grid, toolbar, rowIndex, record) {
            var editButton = toolbar.items.get(1);
            var closeButton = toolbar.items.get(2);
            if (record.data.FStatus == "Invalid") {
                editButton.setDisabled(true);
                editButton.setTooltip("不可用");
                closeButton.setDisabled(true);
                closeButton.setTooltip("不可用");
            }
        };

        var prepareEdit = function (grid, toolbar, rowIndex, record) {
            var editButton = toolbar.items.get(0);
            if (record.data.FStatus == "Invalid") {
                editButton.setDisabled(true);
                editButton.setTooltip("不可用");
            }
        }; 
    </script>
    <title>缺货单列表</title>
</head>
<body>
    <script type="text/javascript" src="/Scripts/ExtTimeOut.js"></script>
    <script type="text/javascript" src="/Scripts/ExtRequiredFieldPluins.js"></script>
    <form id="Form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <!--列表数据源-->
    <ext:Store ID="ShortageOrderListStore" IDMode="Explicit" runat="server" RemoteSort="true"
        SkipIdForNewRecords="false" UseIdConfirmation="false" SerializationMode="Complex">
        <Proxy>
            <ext:HttpProxy Url="/ShortageOrder/ShortageOrderListPaging/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="FId" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="FId" />
                    <ext:RecordField Name="FNumber" />
                    <ext:RecordField Name="FBillDate" />
                    <ext:RecordField Name="FRemark" />
                    <ext:RecordField Name="FSendOrderNumber" />
                    <ext:RecordField Name="FCustomerNumber" />
                    <ext:RecordField Name="FCustomerName" />
                    <ext:RecordField Name="FStatus" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="15" Mode="Raw" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="FCustomerId" Value="#{InputQ_FCustomerId}.getValue()" Mode="Raw" />
            <ext:Parameter Name="FSendOrderNum" Value="#{InputQ_FSendOrderNum}.getValue()" Mode="Raw" />
            <ext:Parameter Name="FStatusId" Value="#{InputQ_FStatusId}.getValue()" Mode="Raw" />
            <ext:Parameter Name="FProductId" Value="#{InputQ_FProductId}.getValue()" Mode="Raw" />
            <ext:Parameter Name="FBillDateFrom" Value="#{InputQ_FBillDateFrom}.getValue()" Mode="Raw" />
            <ext:Parameter Name="FBillDateTo" Value="#{InputQ_FBillDateTo}.getValue()" Mode="Raw" />
        </BaseParams>
    </ext:Store>
    <ext:Store ID="CustomerStore" runat="server" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/Customer/CustomerListPaging/" />
        </Proxy>
        <Reader>
            <ext:JsonReader Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="FId" />
                    <ext:RecordField Name="FName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="2147483647" Mode="Raw" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
        </BaseParams>
    </ext:Store>
    <ext:Store ID="OrderStatusStore" runat="server" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/ShortageOrder/ShortageOrderStatusList/" />
        </Proxy>
        <Reader>
            <ext:JsonReader Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="FID" />
                    <ext:RecordField Name="FName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="ProductsStore" runat="server" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/Product/ProductListPaging/" />
        </Proxy>
        <Reader>
            <ext:JsonReader Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="ProductId" />
                    <ext:RecordField Name="ProductName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="2147483647" Mode="Raw" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
        </BaseParams>
    </ext:Store>
    <ext:Store ID="ShortageOrderDetailStore" IDMode="Explicit" runat="server" RemoteSort="true"
        WarningOnDirty="false" SkipIdForNewRecords="false" UseIdConfirmation="false"
        SerializationMode="Complex">
        <Proxy>
            <ext:HttpProxy Url="/ShortageOrder/ShortageOrderDetailListPaging/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="FId" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="FId" />
                    <ext:RecordField Name="FParentId" />
                    <ext:RecordField Name="FParentNumber" />
                    <ext:RecordField Name="FStatus" />
                    <ext:RecordField Name="FProductId" />
                    <ext:RecordField Name="FProductNumber" />
                    <ext:RecordField Name="FProductName" />
                    <ext:RecordField Name="FShortageNumber" />
                    <ext:RecordField Name="FReturnNumber" />
                    <ext:RecordField Name="FRemark" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="15" Mode="Raw" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="FId" Value="#{FIdH}.getValue()" Mode="Raw" />
        </BaseParams>
    </ext:Store>
    <!--当前编辑帐号的FId-->
    <ext:Hidden ID="FIdH" IDMode="Explicit" runat="server" Text="" AutoDataBind="true">
    </ext:Hidden>
    <ext:Viewport ID="Viewport1" runat="server" Layout="border">
        <Items>
            <ext:Panel ID="ShortageOrderPanel" runat="server" Region="North" Split="true" Header="false"
                Layout="BorderLayout" Height="280">
                <Items>
                    <ext:FormPanel ID="SearchFormPanel" runat="server" Title="筛选条件" Region="West" Width="270"
                        Split="true" Collapsible="true" Layout="FormLayout" Padding="5" LabelWidth="70">
                        <Items>
                            <ext:TextField ID="InputQ_FSendOrderNum" runat="server" FieldLabel="送货单号" AnchorHorizontal="100%"
                                Width="180" />
                            <ext:ComboBox ID="InputQ_FCustomerId" StoreID="CustomerStore" runat="server" FieldLabel="客户"
                                LabelWidth="70" DisplayField="FName" ValueField="FId" AllowBlank="true" EmptyText="请选择客户..."
                                Width="180" Flex="2" Editable="true">
                                <Listeners>
                                    <BeforeRender Handler="this.onTriggerClick = this.onTriggerClick.createSequence(function () {
                                                               Ext.net.DirectMethods.CustomersOnTriggerClick();
                                                           });" />
                                </Listeners>
                            </ext:ComboBox>
                            <ext:ComboBox ID="InputQ_FProductId" StoreID="ProductsStore" runat="server" FieldLabel="产品"
                                LabelWidth="70" DisplayField="ProductName" ValueField="ProductId" AllowBlank="true"
                                EmptyText="请选择产品..." Width="180" Flex="2" Editable="true">
                                <Listeners>
                                    <BeforeRender Handler="this.onTriggerClick = this.onTriggerClick.createSequence(function () {
                                                               Ext.net.DirectMethods.ProductsOnTriggerClick();
                                                           });" />
                                </Listeners>
                            </ext:ComboBox>
                            <ext:ComboBox ID="InputQ_FStatusId" StoreID="OrderStatusStore" runat="server" FieldLabel="欠货单状态"
                                DisplayField="FName" ValueField="FID" AllowBlank="true" EmptyText="请选择欠货单状态..."
                                TriggerAction="All" LabelWidth="70" Width="180" />
                            <ext:DateField ID="InputQ_FBillDateFrom" runat="server" FieldLabel="开单日期(从)" AnchorHorizontal="100%"
                                Format="yyyy-MM-dd" />
                            <ext:DateField ID="InputQ_FBillDateTo" runat="server" FieldLabel="开单日期(到)" AnchorHorizontal="100%"
                                Format="yyyy-MM-dd" />
                        </Items>
                        <Buttons>
                            <ext:Button ID="Button5" runat="server" Text="搜索" Icon="Accept">
                                <Listeners>
                                    <Click Fn="INV_ShortageOrder.Mgr.searchList" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="Button6" runat="server" Text="清空" Icon="Cancel">
                                <Listeners>
                                    <Click Fn="INV_ShortageOrder.Mgr.resetSearchFrom" />
                                </Listeners>
                            </ext:Button>
                        </Buttons>
                    </ext:FormPanel>
                    <ext:GridPanel ID="ShortageOrderGridPanel2" runat="server" Border="false" StoreID="ShortageOrderListStore"
                        StripeRows="true" Height="300" TrackMouseOver="true" ClicksToEdit="0" Region="Center">
                        <ColumnModel ID="ColumnModel1" runat="server" DefaultSortable="false">
                            <Columns>
                                <ext:Column ColumnID="FId" DataIndex="FId" Header="编号" Hidden="true">
                                </ext:Column>
                                <ext:Column ColumnID="FNumber" DataIndex="FNumber" Header="欠货单号" Width="150">
                                </ext:Column>
                                <ext:Column ColumnID="FSendOrderNumber" DataIndex="FSendOrderNumber" Header="送货单号"
                                    Width="150">
                                </ext:Column>
                                <ext:Column ColumnID="FBillDate" DataIndex="FBillDate" Header="开单日期">
                                </ext:Column>
                                <ext:Column ColumnID="FCustomerNumber" DataIndex="FCustomerNumber" Header="客户编号">
                                </ext:Column>
                                <ext:Column ColumnID="FCustomerName" DataIndex="FCustomerName" Header="客户姓名">
                                </ext:Column>
                                <ext:Column ColumnID="FStatus" DataIndex="FStatus" Header="状态">
                                    <Renderer Fn="orderStatus" />
                                </ext:Column>
                                <ext:CommandColumn Width="250" Hideable="false">
                                    <Commands>
                                        <ext:GridCommand CommandName="View" Icon="ApplicationViewDetail" Text="查看">
                                        </ext:GridCommand>
                                        <ext:GridCommand CommandName="Edit" Icon="ApplicationFormEdit" Text="修改">
                                        </ext:GridCommand>
                                        <ext:GridCommand CommandName="Close" Icon="Cross" Text="核销">
                                        </ext:GridCommand>
                                        <ext:GridCommand CommandName="Print" Icon="Printer" Text="导出并打印">
                                        </ext:GridCommand>
                                    </Commands>
                                    <PrepareToolbar Fn="prepare" />
                                </ext:CommandColumn>
                            </Columns>
                        </ColumnModel>
                        <Listeners>
                            <Command Fn="INV_ShortageOrder.Mgr.commandHandler" />
                        </Listeners>
                        <BottomBar>
                            <ext:PagingToolbar ID="PagingToolbar1" runat="server" StoreID="ShortageOrderListStore"
                                PageSize="15" />
                        </BottomBar>
                    </ext:GridPanel>
                </Items>
            </ext:Panel>
            <ext:Panel ID="ShortageOrderDetail" runat="server" Region="Center" Split="true" Header="false"
                Layout="BorderLayout" Height="250">
                <Items>
                    <ext:GridPanel ID="GridPanel1" runat="server" Border="false" StoreID="ShortageOrderDetailStore"
                        StripeRows="true" TrackMouseOver="true" ClicksToEdit="0" Region="Center">
                        <ColumnModel ID="ColumnModel2" runat="server" DefaultSortable="false">
                            <Columns>
                                <ext:Column ColumnID="FId" DataIndex="FId" Header="编号" Hidden="true">
                                </ext:Column>
                                <ext:Column ColumnID="FParentId" DataIndex="FId" Header="编号" Hidden="true">
                                </ext:Column>
                                <ext:Column ColumnID="FStatus" DataIndex="FStatus" Header="状态" Hidden="true">
                                </ext:Column>
                                <ext:Column ColumnID="FParentNumber" DataIndex="FParentNumber" Header="欠货单号" Width="150">
                                </ext:Column>
                                <ext:Column ColumnID="FProductNumber" DataIndex="FProductNumber" Header="产品编号">
                                </ext:Column>
                                <ext:Column ColumnID="FProductName" DataIndex="FProductName" Header="产品名称">
                                </ext:Column>
                                <ext:Column ColumnID="FShortageNumber" DataIndex="FShortageNumber" Header="欠货数量">
                                </ext:Column>
                                <ext:Column ColumnID="FReturnNumber" DataIndex="FReturnNumber" Header="归还数量">
                                    <Editor>
                                        <ext:NumberField runat="server" />
                                    </Editor>
                                </ext:Column>
                                <ext:Column ColumnID="FRemark" DataIndex="FRemark" Header="备注状态">
                                </ext:Column>
                                <ext:CommandColumn Width="60" Hideable="false">
                                    <Commands>
                                        <ext:GridCommand CommandName="SaveOrder" Icon="Disk" Text="保存">
                                        </ext:GridCommand>
                                    </Commands>
                                    <PrepareToolbar Fn="prepareEdit" />
                                </ext:CommandColumn>
                            </Columns>
                        </ColumnModel>
                        <Listeners>
                            <Command Fn="INV_ShortageOrder.Mgr.orderDetailCommandHandler" />
                        </Listeners>
                        <BottomBar>
                            <ext:PagingToolbar ID="PagingToolbar2" runat="server" StoreID="ShortageOrderDetailStore"
                                PageSize="15" />
                        </BottomBar>
                    </ext:GridPanel>
                </Items>
            </ext:Panel>
        </Items>
    </ext:Viewport>
    </form>
</body>
</html>
